%ELEMENTADD(X,Y) ADD two Galois Field elements.
%
%   Inputs:
%
%       X,Y     Exponents of the two addends.  The evaluated product
%               is expected to be of the form (a^X) + (a^Y)
%
%   Outputs:
%
%       Z       The exponent of the sum of X and Y.


function z = elementAdd(x,y)

    % To add the two elements, all that is required is to group them in a 
    % vector and use elementReduce().
    if isZero(x)   %if x is zero, then x + y = y
        z = y;
    elseif isZero(y) %if y is zero, then x + y = x
        z = x;
    else
        z = elementReduce([x y]);  %Add the two
    end
end
